//
//  LandmarkRow.swift
//  Landmarks
//
//  Created by Hello Cai on 2020/4/3.
//  Copyright © 2020 Hello Cai. All rights reserved.
//

import SwiftUI

struct LandmarkRow: View {
    var landmark : Landmark
    
    var body: some View {
        HStack {
            /**
             ※※※※ 这里一直报错，加载资源图片失败，原因是添加文件夹Resources时没有add target，导致Build Phase的Copy Bundle Resouces没有图片资源
             ※※※※
            */
            landmark.image.resizable().frame(width: 50, height: 50)
            
            Text(landmark.name)
            Spacer()
            
            if landmark.isFavorite {
                Image(systemName: "star.fill")
                .imageScale(.medium)
                .foregroundColor(.yellow)
            }
        }
    }
}

struct LandmarkRow_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            LandmarkRow(landmark: landmarkData[0])
            LandmarkRow(landmark: landmarkData[1])
        }
        //previewLayout用来设置行视图在列表中的预览大小
        .previewLayout(.fixed(width: 300, height: 70))
    }
}
